package com.jiahua.admin.biz.action;

import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.SessionAware;

import com.jiahua.user.biz.service.CustomerService;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class DashBoardInitAction extends ActionSupport implements SessionAware {

	private static final long serialVersionUID = -3367950621612672506L;
	
	Logger log = Logger.getLogger(DashBoardInitAction.class.getClass());
	
	CustomerService customerService;
	
	private String newMemberCount;
	private String newMemberCountTipInfo;
		
	private Map session;

	public void setCustomerService(CustomerService customerService) {
		this.customerService = customerService;
	}

	public String getNewMemberCount() {
		return newMemberCount;
	}

	public void setNewMemberCount(String newMemberCount) {
		this.newMemberCount = newMemberCount;
	}
	

	public String getNewMemberCountTipInfo() {
		return newMemberCountTipInfo;
	}

	public void setNewMemberCountTipInfo(String newMemberCountTipInfo) {
		this.newMemberCountTipInfo = newMemberCountTipInfo;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = (Map) session;
	}

	@Override
	public String execute() throws Exception {
		
		int size = customerService.listAllCustomer().size();
		log.debug("size : " +  size);
		newMemberCount = String.valueOf(customerService.listAllCustomer().size());
		newMemberCountTipInfo = "" + size + " new members.";
		session.put("newMemberCount", newMemberCount);
		session.put("newMemberCountTipInfo", newMemberCountTipInfo);
		System.out.println("size : " +  size);
		return Action.SUCCESS;
	}

}
